package com.jawabra.school;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.Toast;

import com.jawabra.school.model.Classroom;
import com.jawabra.school.model.Student;
import com.school.android.R;

public class AddstudentActivity extends Activity
{
	Classroom class1;
	EditText e1;
	EditText e2;
	EditText e3;
	EditText e4;
	EditText e5;
	EditText e6;
	EditText e7;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
	    class1=new Classroom();
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_addstudent);
		Toast st = Toast.makeText(AddstudentActivity.this,"double touch to delete text", 3000);
		st.show();
		e1 = (EditText) findViewById(R.id.editText1);
		e2 = (EditText) findViewById(R.id.editText2);
		e3 = (EditText) findViewById(R.id.editText3);
		e4 = (EditText) findViewById(R.id.editText4);
		e5 = (EditText) findViewById(R.id.editText5);
		e6 = (EditText) findViewById(R.id.editText6);
		e7 = (EditText) findViewById(R.id.editText7);
		e1.setText((class1.studentsNum)+"is");
		e1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				e1.setText("");
				Toast t1=Toast.makeText(AddstudentActivity.this,"id",2000);
				t1.show();
			}
		});
		e2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				e2.setText("");
				Toast t1=Toast.makeText(AddstudentActivity.this,"first name",2000);
				t1.show();
			}
		});
		e3.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				e3.setText("");
				Toast t1=Toast.makeText(AddstudentActivity.this,"last name",2000);
				t1.show();
			}
		});
		e4.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				e4.setText("");
				Toast t1=Toast.makeText(AddstudentActivity.this,"phisics grade",2000);
				t1.show();
			}
		});
		e5.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				e5.setText("");
				Toast t1=Toast.makeText(AddstudentActivity.this,"math grade",2000);
				t1.show();
			}
		});
		e6.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				e6.setText("");
				Toast t1=Toast.makeText(AddstudentActivity.this,"english grade",2000);
				t1.show();
			}
		});
		e7.setOnClickListener(new OnClickListener() {
					
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						e7.setText("");
						Toast t1=Toast.makeText(AddstudentActivity.this,"bio grade",2000);
						t1.show();
					}
				});

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_addstudent, menu);
		return true;
	}

	public void save(View view)
	{
		class1.student[class1.studentsNum]=new Student();
		class1.student[class1.studentsNum].Id = e1.getText().toString();
		class1.student[class1.studentsNum].firstName = e2.getText().toString();
		class1.student[class1.studentsNum].lastName = e3.getText().toString();
		class1.student[class1.studentsNum].phisics = e4.getText().toString();
		class1.student[class1.studentsNum].math = e5.getText().toString();
		class1.student[class1.studentsNum].english = e6.getText().toString();
		class1.student[class1.studentsNum].bio = e7.getText().toString();
		class1.studentsNum++;
		Intent intent = new Intent(AddstudentActivity.this,MainActivity.class);
		intent.putExtra("myclass",class1);
		startActivity(intent);
	}
}